package com.kk.framework.ui;

import java.io.Serializable;
import java.util.HashMap;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Div;
import org.zkoss.zul.Include;
import org.zkoss.zul.West;

import com.kk.framework.ui.framenorth.ToolPanel;
import com.kk.framework.util.Constants;
import com.kk.framework.util.SpringScopes;

@Service("pageService")
@Scope(SpringScopes.SESSION)
public class SystemPageManager implements Serializable
{	
	private static final long serialVersionUID = -3819537208170920517L;
	
	/**
	 * 获取系统的Page页面，一般不使用
	 * @author 杨晓康
	 */
	public Page getCurrentPage()
	{
		return Executions.getCurrent().getDesktop().getPage(Constants.PAGE_NAME_MAIN);
	}

	/**
	 * 获取主框架North下的Include组件
	 * @author 杨晓康
	 * @return Include
	 */
	public Borderlayout getMainContent()
	{
		Borderlayout viewPort = (Borderlayout)this.getCurrentPage().getFellow("ViewPort");
		Borderlayout mainContent = (Borderlayout)viewPort.getCenter().getChildren().get(0);
		return mainContent;
	}


	/**
	 * 获取North工具栏面板
	 * @author 杨晓康
	 */
	public ToolPanel getNorthToolBar()
	{
		Page currPage = this.getCurrentPage();
		ToolPanel navBar = (ToolPanel)currPage.getFellowIfAny("ModuleNavContainer");
		return navBar;
	}

	/**
	 * 获取West导航面板
	 * @author 杨晓康
	 */
	public West getWestModuleNavBar()
	{
		Page currPage = this.getCurrentPage();
		West navBar = (West)currPage.getFellowIfAny("ViewPort_West");
		return navBar;
	}

	public Div getWindowParent()
	{
		Page currPage = this.getCurrentPage();
		Div winParent = (Div) currPage.getFellowIfAny("WindowParent");
		return winParent;
	}

}
